﻿using System;
using System.Collections;
using System.Windows.Forms;

namespace NLP
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnConvert_Click(object sender, EventArgs e)
        {
            rtbProcess.Text = rtbParagraph.Text;
            ArrayList arlOriginal = new ArrayList();
            ArrayList arlToReplace = new ArrayList();

            arlOriginal.Add("abcd"); arlToReplace.Add("fever");
            arlOriginal.Add("xyz"); arlToReplace.Add("Asthma");

            int nPos = 0;
            for (int i = 0; i < rtbProcess.Text.Length; i++)
            {
                if (rtbProcess.Text.Substring(i, 1) == " ")
                {                    
                    for (int j = 0; j < arlOriginal.Count; j++)
                    {                        
                        if (rtbProcess.Text.Substring(nPos, i - nPos).Trim() == arlOriginal[j].ToString())
                        {
                            rtbOutput.Text = rtbProcess.Text.Replace(rtbProcess.Text.Substring(nPos, i - nPos).Trim(), arlToReplace[j].ToString());
                            rtbProcess.Text = rtbOutput.Text;
                        }
                    }
                    nPos = i;
                }
                else
                {                    
                    if (i == rtbProcess.Text.Length - 1)
                    {
                        for (int j = 0; j < arlOriginal.Count; j++)
                        {                            
                            if (rtbProcess.Text.Substring(nPos, i + 1 - nPos).Trim() == arlOriginal[j].ToString())
                            {
                                rtbOutput.Text = rtbProcess.Text.Replace(rtbProcess.Text.Substring(nPos, i + 1 - nPos).Trim(), arlToReplace[j].ToString());
                                rtbProcess.Text = rtbOutput.Text;
                            }
                        }
                    }
                }
            }
            rtbProcess.Text = rtbParagraph.Text;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            rtbParagraph.Text = "I have abcd";
            MessageBox.Show("Test", "sdf");
        }
    }
}
